package com.lizemin.order.controller;

import com.lizemin.common.entity.RespBean;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Enumeration;
import java.util.HashMap;

/**
 * @author lzm
 * @date 2025/3/29 11:35
 * @description
 */
@Slf4j
@RestController
public class TestController {

    @GetMapping("/getAllRequestHeaders")
    public RespBean getAllRequestHeaders(HttpServletRequest request) {
        log.info("返回所有请求头");
        Enumeration<String> headerNames = request.getHeaderNames();
        HashMap<String, String> reqHeaders = new HashMap<>();
        while (headerNames.hasMoreElements()) {
            String headerName = headerNames.nextElement();
            String headerValue = request.getHeader(headerName);
            log.info("headerName:{},headerValue:{}", headerName, headerValue);
            reqHeaders.put(headerName, headerValue);
        }
        return RespBean.success(reqHeaders);
    }

    @GetMapping("/getAllResponseHeaders")
    public RespBean getAllResponseHeaders() {
        return RespBean.success();
    }

}
